<?php
	include("../includes/main_inc.php");
	
	
	if($_POST['Submit']){
		if($_POST['password']==$_POST['password2']){
			if(!$_POST['SendEmail'])$_POST['SendEmail']="N";
			if(!$_POST['AutoApproval'])$_POST['AutoApproval']="N";
			$m= new UpdateDatabase();
			$m->AddPosts($_POST,$_FILES);
			$m->AddSkip(array("id"));
			$m->AddTable("affiliatePrograms");
			$m->AddID($_POST['id']);
			$m->DoStuff();
			$Message="Program Updated";
		};
	};
	
	if($_GET['id']) $id=$_GET['id'];
	elseif ($_POST['id']) $id=$_POST['id'];
	
	
	
	
	$r->AddTable("affiliatePrograms");
	$r->AddSearchVar($id);
	$Insert=$r->GetRecord();
	

?><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Affiliate Bubble Administration</title>

<link href="<?=$rootdir?>css/admin.css" rel="stylesheet" type="text/css">
<script src="<?=$rootdir?>jscript/menuArray.js" language="javascript"></script>
<script src="<?=$rootdir?>jscript/clock.js" language="javascript"></script></head>

<body onLoad="funClock();">
<?php include("../includes/header.php"); ?>
<table width="100%" border="0" cellspacing="25" cellpadding="0">
<tr>
<td valign="top" width="240"><div id="menu">
  <?php include("../menu/advertsmenu.php"); ?>
</div></td>
<td align="center" valign="top">

<div id="titleCompact"> Modify A Program
</div>

<div id="contentCompact">
  <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#E9EEF5">
    <tr id="formHeader">
      <td><strong>Enter details below. </strong><strong></strong></td>
    </tr>
    <tr>
      <td align="center" bgcolor="#FFFFFF"><form name="form1" method="post" action="modify.php">
        <?=$Message;?>
          <table width="400" border="0" cellspacing="0" cellpadding="4">
            <tr>
              <td width="95" height="30">Name:</td>
              <td colspan="3"><input name="Name" type="text" class="formFields" id="Name" value="<?=$Insert['Name'];?>" size="40"></td>
            </tr>
            <tr>
              <td height="30">Description</td>
              <td colspan="3"><textarea name="Description" cols="40" class="formFields" id="Description"><?=$Insert['Description'];?></textarea></td>
            </tr>
            <tr>
              <td height="30">Click Commission </td>
              <td width="86"><label>$
                <input name="CCommission" type="text" class="formFields" id="CCommission" value="<?=$Insert['CCommission'];?>" size="5">
              </label></td>
              <td width="81">Lead Commission </td>
              <td width="106">$
                <input name="LCommission" type="text" class="formFields" id="LCommission" value="<?=$Insert['LCommission'];?>" size="5"></td>
            </tr>
            <tr>
              <td height="30">Sale Commission:</td>
              <td colspan="3"><input name="SCommission" type="text" class="formFields" id="SCommission" value="<?=$Insert['SCommission'];?>" size="5">
                  <select name="SaleType" id="SaleType">
                    <option value="%" <?=($Insert['SaleType']=="%"? "selected":"");?>>%</option>
                    <option value="$" <?=($Insert['SaleType']=="$"? "selected":"");?>>$</option>
                  </select>
              </td>
            </tr>
            <tr>
              <td height="30" align="right"><input name="AutoApproval" type="checkbox" id="AutoApproval" value="Y"  <?=($Insert['AutoApproval']=="Y"? "checked":"");?>></td>
              <td colspan="3">Automatic Affiliate Approval</td>
            </tr>
            <tr>
              <td height="30" align="right"><input name="SendEmail" type="checkbox" id="SendEmail" value="Y"  <?=($Insert['SendEmail']=="Y"? "checked":"");?>></td>
              <td colspan="3">Send Affiliate Transaction Email </td>
            </tr>
            <tr>
              <td><input name="id" type="hidden" id="id" value="<?=$id;?>"></td>
              <td colspan="3"><input type="submit" name="Submit" value="Modify Program" class="formButtonSubmit"></td>
            </tr>
          </table>
        <br>
          <a href="../members/search.php"></a>
      </form></td>
    </tr>
  </table>
</div>

</td>
</tr>
</table>
</body>
</html>
